package com.algorithm.prim;

public class PrimAlgorithm {
    public static void main(String[] args) {
        // 测试图创建
        char[] data = {'A', 'B', 'C', 'D', 'E', 'F', 'G'};
        int verxs = data.length;
        //邻接矩阵的关系使用二维数组表示1000表示两个点不联通
        int[][] weight ={
                {1000, 5, 7, 1000, 1000, 1000, 2},
                {5, 1000, 1000, 9, 1000, 1000, 3},
                {7, 1000, 1000, 1000, 8, 1000, 1000},
                {1000, 9, 1000, 1000, 1000, 4, 1000},
                {1000, 1000, 8, 1000, 1000, 5, 4},
                {1000, 1000, 1000, 4, 5, 1000, 6},
                {2, 3, 1000, 1000, 4, 6,1000}};
        Graph graph = new Graph(verxs,data,weight);
        //根据传入的图获取该图的最小生成树
        MinTree minTree = new MinTree(graph);
        minTree.showGraph();
        minTree.prim(graph,1);
    }
}


